<template>
  <!-- 收藏容器 -->
  <div class="collectionContainer">
    <MyHeader
      icon="el-icon-collection-tag"
      text="我的收藏"
    />
    <!-- 内容版心 -->
    <div class="contentContainer clearfix">
      <div class="contentItem"  v-for="(item,index) in shopCartList" :key="item.id">
        <img :src="item.imgUrl" >
        <p>{{item.skuName}}</p>
        <span>{{item.sourceType}}</span>
        <i>{{item.skuId}}</i>
        <s>{{item.sourceId}}</s>
        <b @click="removeX(index)">X</b>
      </div>
    </div>
    <Pagination style="text-align: center" :total="shopCartList.length"/>
  </div>
</template>

<script>
import { reqShopCart } from "@/api";
export default {
  data(){
    return{
       shopCartList:{},
    }
  },
  name: "Details",
  methods:{
     async getShopCart() {
      let result = await reqShopCart();
      if(result.data[0]){
        this.shopCartList=result.data[0].cartInfoList
      }
    },
    // 删除
    removeX(index){
      this.shopCartList.splice(index,1)
    }
  },
   mounted(){
      this.getShopCart()
   }
}
</script>

<style scoped lang="less">
* {
  margin: 0;
  padding: 0;
}
// 收藏容器
.collectionContainer {
  width: 100%;
  background: #eee;

  //  内容区域
  .contentContainer {
    padding: 20px 0 30px 0;
    width: 1220px;
    margin: 0 auto;
    .contentItem {
      float: left;
      margin-right: 1%;
      width: 19%;
      background: #fff;
      height: 300px;
      box-sizing: border-box;
      box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
      padding: 10px;
      text-align: center;
      transition: 0.5s;
      position: relative;
      img {
        height: 60%;
        width: 80%;
        display: block;
        margin: 0 auto;
      }
      p {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin: 10px 0;
      }
      span {
        color: #666;
        font-size: 14px;
        display: block;
        margin-bottom: 15px;
      }
      i,
      s,
      b {
        font-style: normal;
      }
      i {
        color: red;
        margin-right: 10px;
      }
      s {
        color: #666;
      }
      b {
        position: absolute;
        right: 15px;
        top: 10px;
        cursor: pointer;
      }
      &:hover {
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
      }
    }
  }
}
</style>